home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue24 / pgtray3x / PGTRAY3X.ZIP / Setup.exe / MAIN.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-06-28  |  35.8 KB  |  1,210 lines

  1. (*
  2. ================================================================================
  3. Animated TrayIcon VCL Demo
  4. ================================================================================
  5.   Credits:
  6.   This demo makes use of the source code for the freeware "URL Label" component
  7.   by Ahto Tanner.  While the component is not being used directly, it's source
  8.   is being used to create the URL for our home page that appears on the last
  9.   screen of this demo.  Thanks Ahto for the good work.
  10.  
  11.   For more information on the "URL Label" component:
  12.       URL Label
  13.       Freeware - created by Ahto Tanner (www.estpak.ee/~ahto)
  14.       Special thanks to Chad Z. Hower from Phoenix Business Enterprises
  15.  
  16.   Notes:
  17.   For those who are interested, navigation in this demo occurs between pages
  18.   and between steps in a page.  Step navigation generally speaking relates
  19.   to the hiding and showing of bullets, and page navigation relates to
  20.   displaying a high level feature of the Animated TrayIcon VCL.
  21. ================================================================================
  22. *)
  23. unit Main;
  24.  
  25. interface
  26.  
  27. uses
  28.   WinTypes, WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  29.   ExtCtrls, StdCtrls, Buttons, Menus, ShellApi, ClipBrd, PGTray95;
  30.  
  31. type
  32.   TMainForm = class(TForm)
  33.     Panel1: TPanel;
  34.     Panel: TPanel;
  35.     Panel3: TPanel;
  36.     Pages: TNotebook;
  37.     CurrentPage: TPanel;
  38.     Label1: TLabel;
  39.     Page1Label1: TLabel;
  40.     Panel2: TPanel;
  41.     StatusBar: TPanel;
  42.     Panel4: TPanel;
  43.     NextButton: TButton;
  44.     BackButton: TButton;
  45.     Page2Label1: TLabel;
  46.     Page1Label8: TLabel;
  47.     Button1: TButton;
  48.     Image1: TImage;
  49.     Page2Image1: TImage;
  50.     Page2Bullet: TImage;
  51.     Label2: TLabel;
  52.     Page3Bullet: TImage;
  53.     Label10: TLabel;
  54.     Page3Label: TLabel;
  55.     Image4: TImage;
  56.     Label7: TLabel;
  57.     Image7: TImage;
  58.     Page4Bullet: TImage;
  59.     Label13: TLabel;
  60.     Page4Label1: TLabel;
  61.     Page4Label2: TLabel;
  62.     Page4Label3: TLabel;
  63.     Page5Label3: TLabel;
  64.     Page5Label2: TLabel;
  65.     Page5Label1: TLabel;
  66.     Page5Bullet: TImage;
  67.     Label19: TLabel;
  68.     Image9: TImage;
  69.     Label20: TLabel;
  70.     Page5Label2a: TLabel;
  71.     Page5Label3a: TLabel;
  72.     Page5Label3b: TLabel;
  73.     Page5Label3c: TLabel;
  74.     Page5Label3d: TLabel;
  75.     Page5Label1a: TLabel;
  76.     Page4Label4: TLabel;
  77.     Label14: TLabel;
  78.     Page1Label2: TLabel;
  79.     Page1Label3: TLabel;
  80.     Page1Label4: TLabel;
  81.     Page4Label5a: TLabel;
  82.     Page4Label5b: TLabel;
  83.     Page4Label5c: TLabel;
  84.     URLPopupMenu: TPopupMenu;
  85.     URLCopyMenuItem: TMenuItem;
  86.     Page4Label1b: TLabel;
  87.     Page1Bullet: TImage;
  88.     Page1Label6: TLabel;
  89.     TrayIconPopup: TPopupMenu;
  90.     ShowDemo1: TMenuItem;
  91.     HideDemo1: TMenuItem;
  92.     N1: TMenuItem;
  93.     Registration1: TMenuItem;
  94.     About1: TMenuItem;
  95.     N2: TMenuItem;
  96.     Exit2: TMenuItem;
  97.     TrayIcon: TPGTrayIcon95;
  98.     BrowseForIconDialog: TOpenDialog;
  99.     Page3Label1: TLabel;
  100.     TrackingListBox: TListBox;
  101.     Button2: TButton;
  102.     Label3: TLabel;
  103.     HideIconButton: TButton;
  104.     ShowIconButton: TButton;
  105.     Page2Label4: TLabel;
  106.     Page2Label5: TLabel;
  107.     DisabledIconImage: TImage;
  108.     EnabledIconImage: TImage;
  109.     DisabledLabel: TLabel;
  110.     EnabledLabel: TLabel;
  111.     AnimatedLabel: TLabel;
  112.     Page2Label3: TLabel;
  113.     AnimatedRadioButton: TRadioButton;
  114.     EnabledRadioButton: TRadioButton;
  115.     DisabledRadioButton: TRadioButton;
  116.     Page2Label2: TLabel;
  117.     SamplesComboBox: TComboBox;
  118.     AutoPopupLabel: TLabel;
  119.     ShowHintLabel: TLabel;
  120.     HintLabel: TLabel;
  121.     HintEdit: TEdit;
  122.     ShowHintCheckbox: TCheckBox;
  123.     AutoPopupCheckbox: TCheckBox;
  124.     Page1Label7: TLabel;
  125.     Page4Image1: TImage;
  126.     Page4Image2: TImage;
  127.     Page4Image3: TImage;
  128.     Page1Label5: TLabel;
  129.     procedure FormCreate(Sender: TObject);
  130.     procedure NextButtonClick(Sender: TObject);
  131.     procedure BackButtonClick(Sender: TObject);
  132.     procedure CurrentPageMouseMove(Sender: TObject; Shift: TShiftState; X,
  133.       Y: Integer);
  134.     procedure Button1Click(Sender: TObject);
  135.     procedure AbouttheProgrammersGuild1Click(Sender: TObject);
  136.     procedure HowtoRegister1Click(Sender: TObject);
  137.     procedure URLLabelClick(Sender: TObject);
  138.     procedure URLCopyMenuItemClick(Sender: TObject);
  139.     procedure Page4Label5bMouseMove(Sender: TObject; Shift: TShiftState; X,
  140.       Y: Integer);
  141.     procedure Page5Label2aMouseMove(Sender: TObject; Shift: TShiftState; X,
  142.       Y: Integer);
  143.     procedure Page4Label1bMouseMove(Sender: TObject; Shift: TShiftState; X,
  144.       Y: Integer);
  145.     procedure Page4Label1bClick(Sender: TObject);
  146.     procedure ShowIconButtonClick(Sender: TObject);
  147.     procedure HideIconButtonClick(Sender: TObject);
  148.     procedure AnimatedLabelClick(Sender: TObject);
  149.     procedure EnabledLabelClick(Sender: TObject);
  150.     procedure DisabledLabelClick(Sender: TObject);
  151.     procedure AnimatedRadioButtonClick(Sender: TObject);
  152.     procedure EnabledRadioButtonClick(Sender: TObject);
  153.     procedure DisabledRadioButtonClick(Sender: TObject);
  154.     procedure AutoPopupLabelClick(Sender: TObject);
  155.     procedure ShowHintLabelClick(Sender: TObject);
  156.     procedure AutoPopupCheckboxClick(Sender: TObject);
  157.     procedure ShowHintCheckboxClick(Sender: TObject);
  158.     procedure HintEditChange(Sender: TObject);
  159.     procedure TrayIconClick(Sender: TObject);
  160.     procedure TrayIconDblClick(Sender: TObject);
  161.     procedure SamplesComboBoxChange(Sender: TObject);
  162.     procedure EnabledIconImageDblClick(Sender: TObject);
  163.     procedure DisabledIconImageDblClick(Sender: TObject);
  164.     procedure TrayIconMouseEnter(Sender: TObject; Shift: TShiftState; X,
  165.       Y: Integer);
  166.     procedure TrayIconMouseMove(Sender: TObject; Shift: TShiftState; X,
  167.       Y: Integer);
  168.     procedure TrayIconMouseExit(Sender: TObject; Shift: TShiftState; X,
  169.       Y: Integer);
  170.     procedure Button2Click(Sender: TObject);
  171.     procedure ShowDemo1Click(Sender: TObject);
  172.     procedure HideDemo1Click(Sender: TObject);
  173.     procedure Registration1Click(Sender: TObject);
  174.     procedure About1Click(Sender: TObject);
  175.     procedure Exit2Click(Sender: TObject);
  176.     procedure Page5Label1aClick(Sender: TObject);
  177.     procedure Page5Label1aMouseMove(Sender: TObject; Shift: TShiftState; X,
  178.       Y: Integer);
  179.     procedure TrayIconAppMinimize(Sender: TObject);
  180.     procedure FormShow(Sender: TObject);
  181.   private
  182.     GoingForward: Boolean;
  183.     PlayingForward: Boolean;
  184.     CurrStep: Integer;
  185.   public
  186.     { Used to control step navigation. }
  187.     function PrevStep: Integer;
  188.     function NextStep: Integer;
  189.     function FirstStep: Integer;
  190.     function LastStep: Integer;
  191.     procedure DisplayStep(AStep: Integer);
  192.     function NumberOfStepsInPage(APageIndex: Integer): Integer;
  193.     procedure InitNewStep;
  194.     { Used to control page navigation. }
  195.     function GoBackward: Boolean;
  196.     function GoForward: Boolean;
  197.     function FirstPage: Integer;
  198.     function LastPage: Integer;
  199.     function CurrPage: Integer;
  200.     procedure DisplayPage(APageIndex: Integer);
  201.     procedure DisplayNextPage;
  202.     procedure DisplayPrevPage;
  203.     procedure InitEndOfPage(APageIndex: Integer);
  204.     { Routines used to hide and show objects depending on the direction }
  205.     { that we're heading. (ie Depends on whether the user has clicked the }
  206.     { forward or backward button.) }
  207.     procedure ShowObject(AnObjectName: string);
  208.     procedure ShowBullet(AnObjectName: string);
  209.     procedure ShowBulletedLabel(AStep: Integer);
  210.     function PageObject(AnObjectName: string): TControl;
  211.     function StepObject(AnObjectName: string; AStep: Integer): TControl;
  212.     function PageObjectName(AName: string): string;
  213.     { Other routines. }
  214.     procedure ShowMsg(AMsg: string);
  215.     procedure ShowAbout;
  216.     procedure ShowDemoDialog(Sender: TObject);
  217.     procedure ChangeDirectory(APath: string);
  218.     procedure DisplayHintInStatusBar(Sender: TObject);
  219.     procedure UpdateStatusBar(StatusText: string);
  220.     procedure UpdateNavigationState;
  221.     procedure ShowTrackingMessage(AString: string; X,Y: Integer);
  222.     procedure MakeHotSpotLabel(ALabel: TLabel);
  223.   end;
  224.  
  225. var
  226.   MainForm: TMainForm;
  227.  
  228. const
  229.   crPGURLHand = 6;
  230.  
  231. procedure PGAssert(const Condition: Boolean; const Msg: string);
  232. procedure PGError(const Msg: string);
  233. function PGMax(X, Y: Integer): Integer;
  234. function PGMin(X, Y: Integer): Integer;
  235. function PGCenter(ABreadth, ADistance: Integer): Integer;
  236. procedure PGMakeLabelsWordWrap;
  237.  
  238. function PGFullFilename(AFilename: string): string;
  239.  
  240. implementation
  241.  
  242. {$R *.DFM}
  243.  
  244. { Include a resource file that has some icons in it.  This is used }
  245. { to demonstrate how you can use the Animated TrayIcon VCL with icons }
  246. { that reside in the current executable.  See the "SamplesComboBoxChange" }
  247. { method for some sample code. }
  248. {$IFDEF WIN32}
  249.   {$R ICONS32.RES}
  250. {$ELSE}
  251.   {$R ICONS16.RES}
  252. {$ENDIF}
  253.  
  254. procedure PGAssert(const Condition: Boolean; const Msg: string);
  255. begin
  256.   if Condition then
  257.     exit;
  258.  
  259.   PGError(Msg);
  260.   Halt;
  261. end;
  262.  
  263. procedure PGError(const Msg: string);
  264. begin
  265.   ShowMessage(Msg);
  266. end;
  267.  
  268. function PGMin(X, Y: Integer): Integer;
  269. begin
  270.   Result := X;
  271.   if Y < X then Result := Y;
  272. end;
  273.  
  274. function PGMax(X, Y: Integer): Integer;
  275. begin
  276.   Result := X;
  277.   if Y > X then Result := Y;
  278. end;
  279.  
  280. function PGCenter(ABreadth, ADistance: Integer): Integer;
  281. begin
  282.   Result := (ADistance - ABreadth) div 2;
  283. end;
  284.  
  285.  
  286. { Shows or hides an object, depending on which way the demo is 'playing' }
  287. procedure TMainForm.ShowObject(AnObjectName: string);
  288. var
  289.   AControl: TControl;
  290. begin
  291.   AControl := nil;
  292.  
  293.   AControl := TControl(FindComponent(AnObjectName));
  294.   if (AControl <> nil) then
  295.     AControl.Visible := PlayingForward;
  296. end;
  297.  
  298. { Given an object's name, look's for the object on the main form.  If it is }
  299. { found, the function returns true, and the AControl variable is updated to }
  300. { point to the control we were looking for. }
  301. function TMainForm.PageObject(AnObjectName: string): TControl;
  302. var
  303.   APageObjectName: string;
  304. begin
  305.   Result := nil;
  306.   APageObjectName := PageObjectName(AnObjectName);
  307.   Result := TControl(FindComponent(APageObjectName));
  308.   PGAssert((Result <> nil), 'Object doesnt exist:' + APageObjectName);
  309. end;
  310.  
  311. function TMainForm.StepObject(AnObjectName: string; AStep: Integer): TControl;
  312. var
  313.   APageObjectName: string;
  314. begin
  315.   APageObjectName := AnObjectName + IntToStr(AStep);
  316.   Result := PageObject(APageObjectName);
  317. end;
  318.  
  319. function TMainForm.PageObjectName(AName: string): string;
  320. begin
  321.   Result := Format('Page%d%s', [CurrPage, AName]);
  322. end;
  323.  
  324. { Shows or hides a bullet and another object, depending on the }
  325. { direction we're 'playing'. }
  326. procedure TMainForm.ShowBullet(AnObjectName: string);
  327. var
  328.   Bullet: TControl;
  329.   BulletLeft: Integer;
  330.   BulletTop: Integer;
  331.   ObjectToBullet: TControl;
  332. begin
  333.   { Figure out where to display the bullet. }
  334.   Bullet := PageObject('Bullet');
  335.   ObjectToBullet := PageObject(AnObjectName);
  336.  
  337.   BulletLeft := ObjectToBullet.Left - Bullet.Width - 3;
  338.   BulletTop  := ObjectToBullet.Top + 4;
  339.   Bullet.Left := BulletLeft;
  340.   Bullet.Top  := BulletTop;
  341.  
  342.   { Show the bullet and the object. }
  343.   Bullet.Visible := PlayingForward;
  344.   ObjectToBullet.Visible := PlayingForward;
  345. end;
  346.  
  347. procedure TMainForm.ShowBulletedLabel(AStep: Integer);
  348. begin
  349.   ShowBullet('Label' + IntToStr(AStep));
  350. end;
  351.  
  352. { Used to force examples to hide between pages, and to ensure that bullets }
  353. { are always initially hidden. }
  354. procedure TMainForm.InitNewStep;
  355. begin
  356.   if not GoingForward then
  357.     exit;
  358.  
  359.   PageObject('Bullet').Visible := false;
  360. end;
  361.  
  362. { Enable, Disable, and Modify the navigation buttons depending on where we }
  363. { are in the demo's content. }
  364. procedure TMainForm.UpdateNavigationState;
  365. begin
  366.   { At the first page ... }
  367.   if (CurrPage = FirstPage) and (CurrStep = FirstStep) then
  368.     begin
  369.     BackButton.Enabled := false;
  370.     NextButton.Enabled := true;
  371.     exit;
  372.     end;
  373.  
  374.   { At the last page ... }
  375.   if (CurrPage = LastPage) and (CurrStep = NumberOfStepsInPage(CurrPage)) then
  376.     begin
  377.     BackButton.Enabled := true;
  378.     NextButton.Enabled := false;
  379.     exit;
  380.     end;
  381.  
  382.   { At some page inbetween ... }
  383.   BackButton.Enabled := true;
  384.   NextButton.Enabled := true;
  385. end;
  386.  
  387. procedure TMainForm.DisplayPage(APageIndex: Integer);
  388. begin
  389.   { Display the new page. }
  390.   Pages.PageIndex := APageIndex - 1;
  391.  
  392.   { Show the new pages title in the current page title bar. }
  393.   CurrentPage.Caption := Pages.ActivePage;
  394. end;
  395.  
  396. procedure TMainForm.DisplayNextPage;
  397. begin
  398.   if CurrPage = LastPage then
  399.     exit;
  400.     
  401.   { Display the new page. }
  402.   Pages.PageIndex := Pages.PageIndex + 1;
  403.  
  404.   { Show the new pages title in the current page title bar. }
  405.   CurrentPage.Caption := Pages.ActivePage;
  406.  
  407.   CurrStep := 0;
  408.   GoForward;
  409. end;
  410.  
  411. procedure TMainForm.DisplayPrevPage;
  412. begin
  413.   if CurrPage = FirstPage then
  414.     exit;
  415.     
  416.   Pages.PageIndex := Pages.PageIndex - 1;
  417.   InitEndOfPage(CurrPage);
  418.  
  419.   { Show the new pages title in the current page title bar. }
  420.   CurrentPage.Caption := Pages.ActivePage;
  421. end;
  422.  
  423. function TMainForm.FirstPage: Integer;
  424. begin
  425.   Result := 1;
  426. end;
  427.  
  428. function TMainForm.LastPage: Integer;
  429. begin
  430.   Result := Pages.Pages.Count;
  431. end;
  432.  
  433. function TMainForm.CurrPage: Integer;
  434. begin
  435.   Result := Pages.PageIndex + 1;
  436. end;
  437.  
  438. function TMainForm.GoForward: Boolean;
  439. var
  440.   LastStep: Integer;
  441. begin
  442.   { Go to the next step. }
  443.   GoingForward := true;
  444.   PlayingForward := true;
  445.   
  446.   LastStep := CurrStep;
  447.   CurrStep := NextStep;
  448.  
  449.   { If we're at a different step, then display it. }
  450.   Result := (CurrStep <> LastStep);
  451.   if Result then
  452.     DisplayStep(CurrStep);
  453.   UpdateNavigationState;
  454. end;
  455.  
  456. function TMainForm.FirstStep: Integer;
  457. begin
  458.   Result := 1;
  459. end;
  460.  
  461. function TMainForm.LastStep: Integer;
  462. begin
  463.   Result := 20;
  464. end;
  465.  
  466. function TMainForm.GoBackward: Boolean;
  467. var
  468.   LastStep: Integer;
  469. begin
  470.   { Go to the prev step. }
  471.   GoingForward := false;
  472.   PlayingForward := false;
  473.   DisplayStep(CurrStep);
  474.  
  475.   if (CurrStep = FirstStep) then
  476.     begin
  477.     DisplayPrevPage;
  478.     exit;
  479.     end;
  480.  
  481.   { If we're at a different step, then display it. }
  482.   Result := (CurrStep <> LastStep);
  483.   LastStep := CurrStep;
  484.   CurrStep := PrevStep;
  485.  
  486.   PlayingForward := true;
  487.   if Result then
  488.     DisplayStep(CurrStep);
  489.   UpdateNavigationState;
  490. end;
  491.  
  492. function TMainForm.NextStep: Integer;
  493. begin
  494.   Result := PGMin(CurrStep + 1, LastStep);
  495. end;
  496.  
  497. function TMainForm.PrevStep: Integer;
  498. begin
  499.   Result := PGMax(CurrStep - 1, FirstStep);
  500. end;
  501.  
  502. procedure TMainForm.DisplayHintInStatusBar(Sender: TObject);
  503. begin
  504.   UpdateStatusBar(Application.Hint);
  505. end;
  506.  
  507. procedure TMainForm.FormCreate(Sender: TObject);
  508. begin
  509.   { Change to the project directory so the help file will be available. }
  510.   ChangeDirectory(ExtractFilePath(Application.Exename));
  511.  
  512.   { Show the components help if the user needs help. }
  513.   Application.HelpFile := PGFullFilename('PGTRAY95.HLP');
  514.  
  515.   { Initialize showing hints in the status bar. }
  516.   Application.OnHint := DisplayHintInStatusBar;
  517.   UpdateStatusBar(EmptyStr);
  518.  
  519.   { Initially display the "Smiley Face" sample when the Demo begins. }
  520.   SamplesComboBox.ItemIndex := 0;
  521.   SamplesComboBoxChange(Self);
  522.  
  523.   { Load hand cursors into hot spot labels. }
  524.   MakeHotSpotLabel(Page4Label5b);
  525.   MakeHotSpotLabel(Page4Label1b);
  526.   MakeHotSpotLabel(Page5Label1a);
  527.   MakeHotSpotLabel(Page5Label2a);
  528.  
  529.   { Show the Introduction page of the demo. }
  530.   Pages.ActivePage := 'Introduction';
  531.   CurrStep := 0;
  532.   GoForward;
  533.  
  534.   { Display a dialog that explains what the Demo demonstrates. }
  535.   TrayIcon.HideApplication;
  536.   TrayIcon.PostEvent(ShowDemoDialog);
  537. end;
  538.  
  539. procedure TMainForm.NextButtonClick(Sender: TObject);
  540. begin
  541.   GoForward;
  542. end;
  543.  
  544. procedure TMainForm.BackButtonClick(Sender: TObject);
  545. begin
  546.   GoBackward;
  547. end;
  548.  
  549. { In Delphi 1.0, If you try and "ChDir" to a directory that was }
  550. { extracted from a filename with "ExtractFilePath", you will get an error }
  551. { because "ChDir" doesn't like trailing slashes, and "ExtractFilePath" }
  552. { leaves trailing slashes on.  This removes the trailing slash.  This }
  553. { problem only occurs under Windows 95. }
  554. procedure TMainForm.ChangeDirectory(APath: string);
  555. var
  556.   LastCharPos: Integer;
  557. begin
  558.   { Remove the trailing slash if it exists. }
  559.   LastCharPos := Length(APath);
  560.   if APath[LastCharPos] = '\' then
  561.     Delete(APath, LastCharPos, 1);
  562.  
  563.   { Change to the destination directory. }
  564.   ChDir(APath);
  565. end;
  566.  
  567. procedure TMainForm.UpdateStatusBar(StatusText: string);
  568. begin
  569.   if StatusBar.Caption = StatusText then
  570.     exit;
  571.   StatusBar.Caption := '  ' + StatusText;
  572. end;
  573.  
  574. procedure TMainForm.CurrentPageMouseMove(Sender: TObject;
  575.   Shift: TShiftState; X, Y: Integer);
  576. begin
  577.   UpdateStatusBar(EmptyStr)
  578. end;
  579.  
  580. { Returns a fully qualified filename for files in the demo directory. }
  581. function PGFullFilename(AFilename: string): string;
  582. begin
  583.   Result := ExtractFilePath(Application.Exename) + AFilename;
  584. end;
  585.  
  586. procedure TMainForm.Button1Click(Sender: TObject);
  587. begin
  588.   Application.Terminate;
  589. end;
  590.  
  591. procedure TMainForm.InitEndOfPage(APageIndex: Integer);
  592. begin
  593.   CurrStep := NumberOfStepsInPage(APageIndex);
  594.   case APageIndex of
  595.     2: ;
  596.   end;
  597. end;
  598.  
  599. { Use the MessageBox API call to show our messages to make sure that }
  600. { they are always shown "On Top", regardless of which application currently }
  601. { has the focus. }
  602. procedure TMainForm.ShowMsg(AMsg: string);
  603. var
  604.   APCharMsg: array[0..255] of char;
  605. begin
  606.   StrPCopy(APCharMsg, AMsg);
  607. {$IFDEF WIN32}
  608.   MessageBox(Application.Handle, APCharMsg, 'Animated TrayIcon VCL', mb_OK + mb_SetForeground + mb_IconInformation);
  609. {$ELSE}
  610.   MessageBox(Application.Handle, APCharMsg, 'Animated TrayIcon VCL', mb_OK + mb_IconInformation);
  611. {$ENDIF}
  612. end;
  613.  
  614. procedure TMainForm.ShowAbout;
  615. var
  616.   AMsg: string;
  617. begin
  618.   AMsg := 'Animated TrayIcon VCL v3.0' + #13#13 + 'by The Programmers' + #39 + ' Guild';
  619.   MainForm.ShowMsg(AMsg);
  620. end;
  621.  
  622. procedure TMainForm.AbouttheProgrammersGuild1Click(Sender: TObject);
  623. begin
  624.   ShowAbout;
  625. end;
  626.  
  627. procedure TMainForm.HowtoRegister1Click(Sender: TObject);
  628. begin
  629.   Application.HelpContext(11);
  630. end;
  631.  
  632. { URL Label - See Credits at beginning of unit. }
  633. procedure TMainForm.URLLabelClick(Sender: TObject);
  634. var
  635.   AnUrl: array[0..255] of char;
  636. begin
  637.   StrPCopy(AnUrl, 'http://www.programmersguild.com/');
  638.   ShellExecute(Application.Handle, 'open', AnUrl, nil, nil, SW_NORMAL);
  639. end;
  640.  
  641. { URL Label - See Credits at beginning of unit. }
  642. procedure TMainForm.URLCopyMenuItemClick(Sender: TObject);
  643. var
  644.   AnURLLabel: TLabel;
  645. begin
  646.   AnURLLabel := TLabel(URLPopupMenu.PopupComponent);
  647.   Clipboard.AsText := AnURLLabel.Caption;
  648. end;
  649.  
  650. { URL Label - See Credits at beginning of unit. }
  651. procedure TMainForm.MakeHotSpotLabel(ALabel: TLabel);
  652. begin
  653.   Screen.Cursors[crPGURLHand] := LoadCursor(HInstance, PChar('TPGTRAYICON95HAND'));
  654.   ALabel.Cursor := crPGURLHand;
  655. end;
  656.  
  657. procedure TMainForm.Page4Label5bMouseMove(Sender: TObject;
  658.   Shift: TShiftState; X, Y: Integer);
  659. begin
  660.   UpdateStatusBar('View detailed registration information.');
  661. end;
  662.  
  663. procedure TMainForm.Page5Label2aMouseMove(Sender: TObject;
  664.   Shift: TShiftState; X, Y: Integer);
  665. begin
  666.   UpdateStatusBar('Go to The Programmers' + #39 + ' Guild Home Page.');
  667. end;
  668.  
  669. procedure TMainForm.Page4Label1bMouseMove(Sender: TObject; Shift: TShiftState;
  670.   X, Y: Integer);
  671. begin
  672.   UpdateStatusBar('Go to our online registration service.');
  673. end;
  674.  
  675. procedure TMainForm.Page4Label1bClick(Sender: TObject);
  676. var
  677.   AnUrl: array[0..255] of char;
  678. begin
  679.   StrPCopy(AnUrl, 'http://www.programmersguild.com/');
  680.   ShellExecute(Application.Handle, 'open', AnUrl, nil, nil, SW_NORMAL);
  681. end;
  682.  
  683. procedure TMainForm.ShowIconButtonClick(Sender: TObject);
  684. begin
  685.   { Show the TrayIcon in the system tray. }
  686.   TrayIcon.ShowIcon;
  687. end;
  688.  
  689. procedure TMainForm.HideIconButtonClick(Sender: TObject);
  690. begin
  691.   { Hide the TrayIcon. }
  692.   TrayIcon.HideIcon;
  693. end;
  694.  
  695. procedure TMainForm.AnimatedLabelClick(Sender: TObject);
  696. begin
  697.   { Animates the TrayIcon if it is not already being animated. }
  698.   if not AnimatedRadioButton.Checked then
  699.     AnimatedRadioButton.Checked := true;
  700. end;
  701.  
  702. procedure TMainForm.EnabledLabelClick(Sender: TObject);
  703. begin
  704.   { Enables the TrayIcon if it is not already enabled. }
  705.   if not EnabledRadioButton.Checked then
  706.     EnabledRadioButton.Checked := true;
  707. end;
  708.  
  709. procedure TMainForm.DisabledLabelClick(Sender: TObject);
  710. begin
  711.   { Disables the TrayIcon if it is not already disabled. }
  712.   if not DisabledRadioButton.Checked then
  713.     DisabledRadioButton.Checked := true;
  714. end;
  715.  
  716. procedure TMainForm.AnimatedRadioButtonClick(Sender: TObject);
  717. begin
  718.   { Tell the TrayIcon to display the icons that are listed in }
  719.   { the Animation.Icons property. }
  720.   TrayIcon.State := tsAnimated;
  721. end;
  722.  
  723. procedure TMainForm.EnabledRadioButtonClick(Sender: TObject);
  724. begin
  725.   { Tell the TrayIcon to display the icon in it's "Icon" property. }
  726.   TrayIcon.State := tsEnabled;
  727. end;
  728.  
  729. procedure TMainForm.DisabledRadioButtonClick(Sender: TObject);
  730. begin
  731.   { Tell the TrayIcon to display the icon in it's "DisabledIcon" property. }
  732.   TrayIcon.State := tsDisabled;
  733. end;
  734.  
  735. procedure TMainForm.AutoPopupLabelClick(Sender: TObject);
  736. begin
  737.   { Toggles displaying the right click Popup menu on and off. }
  738.   AutoPopupCheckBox.Checked := not AutoPopupCheckBox.Checked;
  739. end;
  740.  
  741. procedure TMainForm.ShowHintLabelClick(Sender: TObject);
  742. begin
  743.   { Toggles displaying the icon's hint on and off. }
  744.   ShowHintCheckBox.Checked := not ShowHintCheckBox.Checked;
  745. end;
  746.  
  747. procedure TMainForm.AutoPopupCheckboxClick(Sender: TObject);
  748. begin
  749.   { Toggles displaying the Popup menu on right click on/off. }
  750.   TrayIcon.AutoPopup := AutoPopupCheckBox.Checked;
  751. end;
  752.  
  753. procedure TMainForm.ShowHintCheckboxClick(Sender: TObject);
  754. begin
  755.   { Toggles displaying the icon's hint on/off. }
  756.   TrayIcon.ShowHint := ShowHintCheckBox.Checked;
  757. end;
  758.  
  759. procedure TMainForm.HintEditChange(Sender: TObject);
  760. begin
  761.   { Display the hint that the user just typed in. }
  762.   TrayIcon.Hint := HintEdit.Text;
  763. end;
  764.  
  765. procedure TMainForm.TrayIconClick(Sender: TObject);
  766. var
  767.   AMsg: string;
  768. begin
  769.   { Figure out which mouse button was clicked. }
  770.   case TrayIcon.ClickedMouseButton of
  771.     mbLeft:   AMsg := 'Left Single Click !!!';
  772.     mbMiddle: AMsg := 'Middle Single Click !!!';
  773.     mbRight:  AMsg := 'Right Single Click !!!';
  774.   end;
  775.  
  776.   { Respond to the icon begin double clicked. }
  777.   ShowMsg(AMsg);
  778. end;
  779.  
  780. procedure TMainForm.TrayIconDblClick(Sender: TObject);
  781. var
  782.   AMsg: string;
  783. begin
  784.   { Figure out which mouse button was double clicked. }
  785.   case TrayIcon.ClickedMouseButton of
  786.     mbLeft:   AMsg := 'Left Double Click !!!';
  787.     mbMiddle: AMsg := 'Middle Double Click !!!';
  788.     mbRight:  AMsg := 'Right Double Click !!!';
  789.   end;
  790.  
  791.   { Respond to the icon begin double clicked. }
  792.   ShowMsg(AMsg);
  793. end;
  794.  
  795. procedure TMainForm.SamplesComboBoxChange(Sender: TObject);
  796. begin
  797.   { Make sure that we're in the application directory, so }
  798.   { we can find the sample icons. }
  799.   ChangeDirectory(ExtractFilePath(Application.Exename));
  800.  
  801.   { Load the group of icons that the user selected. }
  802.   { i.e. Make the TrayIcon display:  }
  803.   {       1. A Smiley Face.          }
  804.   {       2. A Burning Trashcan.     }
  805.   {       3. A Flashing light bulb.  }
  806.   case SamplesComboBox.ItemIndex of
  807.  
  808.     0: { Smiley Face !!! }
  809.       begin
  810.       { Set the icons that will be displayed when the }
  811.       { TrayIcon is in its enabled and disabled states. }
  812.       TrayIcon.Icon.LoadFromFile('SMILEY3.ICO');
  813.       TrayIcon.DisabledIcon.LoadFromFile('SAD.ICO');
  814.  
  815.       { Tell the TrayIcon that the icons to be used in the }
  816.       { animation are icon files. }
  817.       TrayIcon.Animation.Options := aoIconsAreFiles;
  818.       TrayIcon.Animation.Icons.Clear;
  819.       TrayIcon.Animation.Icons.Add('SMILEY1.ICO');
  820.       TrayIcon.Animation.Icons.Add('SMILEY2.ICO');
  821.       TrayIcon.Animation.Icons.Add('SMILEY3.ICO');
  822.       TrayIcon.Animation.Icons.Add('SMILEY4.ICO');
  823.       TrayIcon.Animation.Icons.Add('SMILEY3.ICO');
  824.  
  825.       { Make the animation of the face smiling and winking a "slow" }
  826.       { animation so we can see the expressions clearly. }
  827.       TrayIcon.Animation.Interval := 400;
  828.       end;
  829.  
  830.     1: { Flashing Light }
  831.        { Note: The following code sets up the TrayIcon to use icons }
  832.        { that were included as resources in the current executable. }
  833.        { This allows developers to create TrayIcon applications that will }
  834.        { not require external icon files at runtime. }
  835.       begin
  836.       { Set the icons that will be displayed when the }
  837.       { TrayIcon is in its enabled and disabled states. }
  838.       { In the above example, these icons were loaded from }
  839.       { external icon files.  In this example, the icons are }
  840.       { included in the executable, so we load the icons by }
  841.       { using the LoadIcon API call. }
  842.       TrayIcon.Icon.Handle := WinProcs.LoadIcon(HInstance, 'LIGHTON');
  843.       TrayIcon.DisabledIcon.Handle := WinProcs.LoadIcon(HInstance, 'LIGHTOFF');
  844.  
  845.       { Tell the TrayIcon that the icons to be used in the }
  846.       { animation are icon resources that are included in }
  847.       { the current executable.  While the above Icon and DisabledIcon }
  848.       { properties required us to use the LoadIcon API call to load }
  849.       { an icon from the executable, the Animation property takes care }
  850.       { of these details "behind the scenes", once it is has been }
  851.       { told where to look. }
  852.       TrayIcon.Animation.Options := aoIconsInExe;
  853.       TrayIcon.Animation.Icons.Clear;
  854.       TrayIcon.Animation.Icons.Add('LIGHTON');
  855.       TrayIcon.Animation.Icons.Add('LIGHTON');
  856.       TrayIcon.Animation.Icons.Add('LIGHTOFF');
  857.       TrayIcon.Animation.Icons.Add('LIGHTOFF');
  858.       TrayIcon.Animation.Icons.Add('LIGHTON');
  859.       TrayIcon.Animation.Icons.Add('LIGHTOFF');
  860.       TrayIcon.Animation.Icons.Add('LIGHTON');
  861.       TrayIcon.Animation.Icons.Add('LIGHTOFF');
  862.  
  863.       { Make the animation of the light bulb flashing on and off }
  864.       { a "fast" animation. }
  865.       TrayIcon.Animation.Interval := 150;
  866.       end;
  867.  
  868.     2: { Burning Trashcan }
  869.       begin
  870.       { Set the icons that will be displayed when the }
  871.       { TrayIcon is in its enabled and disabled states. }
  872.       TrayIcon.Icon.LoadFromFile('TRASH3.ICO');
  873.       TrayIcon.DisabledIcon.LoadFromFile('NOTRASH.ICO');
  874.  
  875.       { Tell the TrayIcon that the icons to be used in the }
  876.       { animation are icon files. }
  877.       TrayIcon.Animation.Options := aoIconsAreFiles;
  878.       TrayIcon.Animation.Icons.Clear;
  879.       TrayIcon.Animation.Icons.Add('TRASH1.ICO');
  880.       TrayIcon.Animation.Icons.Add('TRASH2.ICO');
  881.       TrayIcon.Animation.Icons.Add('TRASH3.ICO');
  882.  
  883.       { Make the animation of the fire burning in the trashcan }
  884.       { a "fast" animation to simulate the flickering of a fire. }
  885.       TrayIcon.Animation.Interval := 150;
  886.       end;
  887.     end;
  888.  
  889.   { Display the icons for this sample on the form. }
  890.   EnabledIconImage.Picture.Bitmap.Handle := 0;
  891.   DisabledIconImage.Picture.Bitmap.Handle := 0;
  892.   EnabledIconImage.Picture.Icon.Assign(TrayIcon.Icon);
  893.   DisabledIconImage.Picture.Icon.Assign(TrayIcon.DisabledIcon);
  894.  
  895.   { Set the hint of the TrayIcon to display the name of the }
  896.   { current sample being displayed. }
  897.   TrayIcon.Hint := SamplesComboBox.Text;
  898. end;
  899.  
  900. procedure TMainForm.EnabledIconImageDblClick(Sender: TObject);
  901. begin
  902.   { Change the enabled icon to the icon that the user }
  903.   { selected in the browse dialog. }
  904.   if BrowseForIconDialog.Execute then
  905.     begin
  906.     TrayIcon.Icon.LoadFromFile(BrowseForIconDialog.Filename);
  907.     EnabledIconImage.Picture.Bitmap.Handle := 0;
  908.     EnabledIconImage.Picture.LoadFromFile(BrowseForIconDialog.Filename);
  909.     EnabledRadioButton.Checked := true;
  910.     end;
  911. end;
  912.  
  913. procedure TMainForm.DisabledIconImageDblClick(Sender: TObject);
  914. begin
  915.   { Change the disabled icon to the icon that the user }
  916.   { selected in the browse dialog. }
  917.   if BrowseForIconDialog.Execute then
  918.     begin
  919.     TrayIcon.DisabledIcon.LoadFromFile(BrowseForIconDialog.Filename);
  920.     DisabledIconImage.Picture.Bitmap.Handle := 0;
  921.     DisabledIconImage.Picture.LoadFromFile(BrowseForIconDialog.Filename);
  922.     DisabledRadioButton.Checked := true;
  923.     end;
  924. end;
  925.  
  926. procedure TMainForm.TrayIconMouseEnter(Sender: TObject; Shift: TShiftState;
  927.   X, Y: Integer);
  928. begin
  929.   ShowTrackingMessage('Entering TrayIcon', X, Y);
  930. end;
  931.  
  932. procedure TMainForm.TrayIconMouseMove(Sender: TObject; Shift: TShiftState;
  933.   X, Y: Integer);
  934. begin
  935.   ShowTrackingMessage('  Moving over TrayIcon', X, Y);
  936. end;
  937.  
  938. procedure TMainForm.TrayIconMouseExit(Sender: TObject; Shift: TShiftState;
  939.   X, Y: Integer);
  940. begin
  941.   ShowTrackingMessage('  Leaving TrayIcon', X, Y);
  942. end;
  943.  
  944. function PGInStr(TargetString, SubString: string): Boolean;
  945. begin
  946.   Result := Pos(SubString, TargetString) <> 0;
  947. end;
  948.  
  949. procedure TMainForm.ShowTrackingMessage(AString: string; X,Y: Integer);
  950. var
  951.   LastItem: string;
  952.   LastItemIndex: Integer;
  953.   NewItem: string;
  954. begin
  955.   { Figure out the new item string. }
  956.   NewItem := Format('%s at (%d,%d)', [AString, X, Y]);
  957.  
  958.   { Figure out where the new item should go.  If its a moving message and }
  959.   { a moving message was the last message in the list box, update it, }
  960.   { otherwise just tag it onto the end of the list. }
  961.   LastItemIndex := TrackingListBox.Items.Count - 1;
  962.   if LastItemIndex >= 0 then
  963.     begin
  964.     LastItem := TrackingListBox.Items[LastItemIndex];
  965.     if PGInStr(LastItem, 'Moving') and PGInStr(AString, 'Moving') then
  966.       TrackingListBox.Items[LastItemIndex] := NewItem
  967.     else
  968.       TrackingListBox.Items.Add(NewItem);
  969.     end
  970.   else
  971.     TrackingListBox.Items.Add(NewItem);
  972.  
  973.   { Make sure that the last item in the list box is always selected, so }
  974.   { users can see the additions as they happen. }
  975.   TrackingListBox.ItemIndex := TrackingListBox.Items.Count - 1;
  976. end;
  977.  
  978. procedure TMainForm.Button2Click(Sender: TObject);
  979. begin
  980.   TrackingListBox.Clear;
  981. end;
  982.  
  983. procedure TMainForm.ShowDemoDialog(Sender: TObject);
  984. var
  985.   MsgStr: string;
  986. begin
  987.   MsgStr := EmptyStr;
  988.   MsgStr := MsgStr + 'This application demonstrates key features' + #10;
  989.   MsgStr := MsgStr + 'of the Animated TrayIcon VCL.' + #10#10;
  990.   MsgStr := MsgStr + 'Click OK, and right click the "Smiley Face"' + #10;
  991.   MsgStr := MsgStr + 'TrayIcon to display a Popup menu and' + #10;
  992.   MsgStr := MsgStr + 'further explore the components features.' + #10;
  993.  
  994.   { Display the introductory dialog. }
  995.   ShowMsg(MsgStr);
  996. end;
  997. procedure TMainForm.ShowDemo1Click(Sender: TObject);
  998. begin
  999.   { Shows the application by showing both the Main Form and }
  1000.   { the Application's task bar icon. }
  1001.   TrayIcon.ShowApplication;
  1002. end;
  1003.  
  1004. procedure TMainForm.HideDemo1Click(Sender: TObject);
  1005. begin
  1006.   { Hide's the application by hiding both the Main Form and }
  1007.   { the Application's task bar icon. }
  1008.   TrayIcon.HideApplication;
  1009. end;
  1010.  
  1011. procedure TMainForm.Registration1Click(Sender: TObject);
  1012. begin
  1013.   { Display the Registration help topic in the component help file. }
  1014.   Application.HelpJump('Ordering_Information_Order_Form');
  1015. end;
  1016.  
  1017. procedure TMainForm.About1Click(Sender: TObject);
  1018. begin
  1019.   ShowAbout;
  1020.   exit;
  1021.   { Display the About information for this component. }
  1022.   Application.HelpJump('About');
  1023. end;
  1024.  
  1025. procedure TMainForm.Exit2Click(Sender: TObject);
  1026. begin
  1027.   { Exit the Demo. }
  1028.   Application.Terminate;
  1029. end;
  1030.  
  1031. procedure TMainForm.DisplayStep(AStep: Integer);
  1032. begin
  1033.   InitNewStep;
  1034.   case CurrPage of
  1035.     1: { Page 1 }
  1036.        case AStep of
  1037.         1: ShowBulletedLabel(1);
  1038.         2: ShowBulletedLabel(2);
  1039.         3: ShowBulletedLabel(3);
  1040.         4: ShowBulletedLabel(4);
  1041.         5: ShowBulletedLabel(5);
  1042.         6: ShowBulletedLabel(6);
  1043.         7: ShowBulletedLabel(7);
  1044.         8: ShowObject('Page1Label8');
  1045.         9: DisplayNextPage;
  1046.        end;
  1047.  
  1048.     2: { Page 2 }
  1049.        case AStep of
  1050.         1: begin
  1051.            ShowBullet('Image1');
  1052.            ShowObject('Page2Label1');
  1053.            end;
  1054.         2: begin
  1055.            ShowBulletedLabel(2);
  1056.            ShowObject('SamplesComboBox');
  1057.            end;
  1058.         3: begin
  1059.            ShowBulletedLabel(3);
  1060.            ShowObject('AnimatedRadioButton');
  1061.            ShowObject('AnimatedLabel');
  1062.            ShowObject('EnabledRadioButton');
  1063.            ShowObject('EnabledLabel');
  1064.            ShowObject('EnabledIconImage');
  1065.            ShowObject('DisabledRadioButton');
  1066.            ShowObject('DisabledLabel');
  1067.            ShowObject('DisabledIconImage');
  1068.            end;
  1069.         4: begin
  1070.            ShowBulletedLabel(4);
  1071.            ShowObject('ShowIconButton');
  1072.            ShowObject('HideIconButton');
  1073.            end;
  1074.         5: begin
  1075.            ShowBulletedLabel(5);
  1076.            ShowObject('ShowHintLabel');
  1077.            ShowObject('ShowHintCheckBox');
  1078.            ShowObject('AutoPopupLabel');
  1079.            ShowObject('AutoPopupCheckBox');
  1080.            ShowObject('HintLabel');
  1081.            ShowObject('HintEdit');
  1082.            end;
  1083.         6: begin
  1084.            TrackingListBox.Clear;
  1085.            DisplayNextPage;
  1086.            end;
  1087.        end;
  1088.  
  1089.     3: { Page 3 }
  1090.        case AStep of
  1091.         1: ShowBulletedLabel(1);
  1092.         2: DisplayNextPage;
  1093.        end;
  1094.  
  1095.     4: { Page 4 }
  1096.        case AStep of
  1097.         1: begin
  1098.            ShowObject('Page4Label1');
  1099.            ShowObject('Page4Label1b');
  1100.            ShowBullet('Image1');
  1101.            end;
  1102.         2: begin
  1103.            ShowObject('Page4Label2');
  1104.            ShowBullet('Image2');
  1105.            end;
  1106.         3: begin
  1107.            ShowObject('Page4Label3');
  1108.            ShowBullet('Image3');
  1109.            end;
  1110.         4: ShowBulletedLabel(4);
  1111.         5: begin
  1112.            ShowObject('Page4Label5a');
  1113.            ShowObject('Page4Label5b');
  1114.            ShowObject('Page4Label5c');
  1115.            end;
  1116.         6: DisplayNextPage;
  1117.        end;
  1118.  
  1119.     5: { Page 5 }
  1120.        case AStep of
  1121.         1: begin
  1122.            ShowBulletedLabel(1);
  1123.            ShowObject('Page5Label1a');
  1124.            end;
  1125.         2: begin
  1126.            ShowBulletedLabel(2);
  1127.            ShowObject('Page5Label2a');
  1128.            end;
  1129.         3: begin
  1130.            ShowBulletedLabel(3);
  1131.            ShowObject('Page5Label3A');
  1132.            ShowObject('Page5Label3B');
  1133.            ShowObject('Page5Label3C');
  1134.            ShowObject('Page5Label3D');
  1135.            end;
  1136.         4: DisplayNextPage;
  1137.        end;
  1138.     end;
  1139. end;
  1140.  
  1141. function TMainForm.NumberOfStepsInPage(APageIndex: Integer): Integer;
  1142. begin
  1143.   case APageIndex of
  1144.     1: Result := 8;
  1145.     2: Result := 5;
  1146.     3: Result := 1;
  1147.     4: Result := 5;
  1148.     5: Result := 3;
  1149.   else
  1150.     Result := FirstStep;
  1151.   end;
  1152. end;
  1153.  
  1154. procedure TMainForm.Page5Label1aClick(Sender: TObject);
  1155. var
  1156.   AnUrl: array[0..255] of char;
  1157. begin
  1158.   StrPCopy(AnUrl, 'mailto: feedback@programmersguild.com');
  1159.   ShellExecute(Application.Handle, 'open', AnUrl, nil, nil, SW_NORMAL);
  1160. end;
  1161.  
  1162. procedure TMainForm.Page5Label1aMouseMove(Sender: TObject;
  1163.   Shift: TShiftState; X, Y: Integer);
  1164. begin
  1165.   UpdateStatusBar('Contact The Programmers' + #39 + ' Guild via E-mail.');
  1166. end;
  1167.  
  1168. procedure TMainForm.TrayIconAppMinimize(Sender: TObject);
  1169. begin
  1170.   { Make sure that if someone minimizes the Demo they have a }
  1171.   { way of showing the Demo again - ie Make sure they haven't }
  1172.   { turned off the TrayIcon's PopupMenu, which allows them to }
  1173.   { show the demo when it's minimized in the System Tray. } 
  1174.   if not AutoPopupCheckBox.Checked then
  1175.     AutoPopupCheckBox.Checked := true;
  1176. end;
  1177.  
  1178. procedure TMainForm.FormShow(Sender: TObject);
  1179. begin
  1180.   PGMakeLabelsWordWrap;
  1181. end;
  1182.  
  1183. procedure PGMakeLabelsWordWrap;
  1184. var
  1185.   AFormCount: Integer;
  1186.   AComponentCount: Integer;
  1187.   i: Integer;
  1188.   j: Integer;
  1189.   ALabel: TLabel;
  1190.   AForm: TForm;
  1191. begin
  1192.   AFormCount := Screen.FormCount;
  1193.  
  1194.   for i := 0 to AFormCount - 1 do
  1195.     begin
  1196.     AForm := Screen.Forms[i];
  1197.     AComponentCount := AForm.ComponentCount;
  1198.     for j := 0 to AComponentCount - 1 do
  1199.       begin
  1200.       if AForm.Components[j] is TLabel then
  1201.         begin
  1202.         ALabel := TLabel(AForm.Components[j]);
  1203.         ALabel.WordWrap := true;
  1204.         end;
  1205.       end;
  1206.     end;
  1207. end;
  1208.  
  1209. end.
  1210.